package com.leyou.item.client;

import com.leyou.common.pojo.PageResult;
import com.ly.plus.dto.SpecGroupDTO;
import com.ly.plus.dto.SpuDTO;
import com.ly.plus.entity.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: ycs
 * Date: 2020/8/23
 * Time: 20:05
 * Description: No Description
 * item微服务提供接口
 */
@FeignClient("item-service")//1,指定服务id 2,提供服务对应方法访问地址要一致
public interface ItemClient {
    /**
     * 查询规格参数
     * @param gid//规格组id
     * @param cid//分类id
     * @param searching//是否参与搜索
     * @return
     */
    @GetMapping("/spec/params")
    public List<SpecParam>findSpecParams(@RequestParam(value = "gid",required = false)Long gid,
                                                         @RequestParam(value = "cid",required = false)Long cid,
                                                         @RequestParam(value = "searching",required = false)Boolean searching
    );
    /**
     * 根据spuid获取SpuDetail
     * @param id
     * @return
     */
    @GetMapping("/spu/detail")
    public SpuDetail findSpuDetailById(@RequestParam("id")Long id);
    /**
     * 根据spuid获取sku集合
     * @param id
     * @return
     */
    @GetMapping("/sku/of/spu")
    public List<Sku> findSkuBySpuId(@RequestParam("id")Long id);
    /**
     * 分页查询商品
     * @param key 搜索关键字
     * @param saleable //是否根据上下架查询
     * @param page //当前页
     * @param rows //一页展示总数
     *    //入口:http://api.leyou.com/api/item/spu/page?key=&saleable=true&page=1&rows=5
     * @return
     */
    @GetMapping("/spu/page")
    public PageResult<SpuDTO> findGoodsByPage(@RequestParam(value = "key",required = false)String key,
                                                             @RequestParam(value = "saleable",required = false)Boolean saleable,
                                                             @RequestParam(value = "page",required = false)Long page,
                                                             @RequestParam(value = "rows",required = false)Long rows);
    /**
     * 根据id集查询分类
     * @param ids
     * @return
     */
    @GetMapping("/category/list")
    public List<Category>findCategorysByIds(@RequestParam("ids")List<Long>ids);
    @GetMapping("/brand/list/of/ids")
    public List<Brand>findBrandByIds(@RequestParam("ids")List<Long>ids);
    /**
     * 根据id获取spu
     * @param id
     * @return
     */
    @GetMapping("/spu/{id}")
    public SpuDTO findSpuById(@PathVariable("id")Long id);
    /**
     *
     * @param id
     * @return根据id查询单条数据
     */
    @GetMapping("/brand/{id}")
    public Brand findBrandById(@PathVariable("id")Long id);
    /**
     * 根据分类id查询规格组和组内参数
     * @param cid
     * @return
     */
    @GetMapping("/spec/of/category")
    public List<SpecGroupDTO>findSpecGroupDTOsByCid(@RequestParam("id")Long cid);

}
